package com.myprofile.app;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;

import java.util.ArrayList;


public class MainActivity extends Activity {

    private ViewPager viewPager;

    private View firstlayout;
    private View secondLayout;
    private View thirdlayout;
    private View forthLayout;
    private View fifthlayout;
    private View sixthLayout;

    private View decorView;

    private final ArrayList<View> views = new ArrayList<View>();
    private final ArrayList<String> titles = new ArrayList<String>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        decorView = getWindow().getDecorView();

        viewPager = (ViewPager) findViewById(R.id.view_pager);

        LayoutInflater layoutInflater = LayoutInflater.from(this);

        firstlayout = layoutInflater.inflate(R.layout.first_page, null);
        secondLayout = layoutInflater.inflate(R.layout.second_page, null);
        thirdlayout = layoutInflater.inflate(R.layout.third_page, null);
        forthLayout = layoutInflater.inflate(R.layout.forth_page, null);
        fifthlayout = layoutInflater.inflate(R.layout.fifth_page, null);
        sixthLayout = layoutInflater.inflate(R.layout.sixth_page, null);

        views.add(firstlayout);
        views.add(secondLayout);
        views.add(thirdlayout);
        views.add(forthLayout);
        views.add(fifthlayout);
        views.add(sixthLayout);

        titles.add("1");
        titles.add("2");
        titles.add("3");
        titles.add("4");
        titles.add("5");
        titles.add("6");

        viewPager.setAdapter(new ViewPagerAdapter(titles, views));
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus) {
            decorView.setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        }
    }
}

